#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);

    //创建一个CentralWidget, 并将其设置为MainWindow的中心部件
    _login_dia = new LoginDialog(this);
    setCentralWidget(_login_dia);

    //点击注册按钮触发switchRegister信号，触发SlotsSwitchReg函数
    connect(_login_dia, &LoginDialog::switchRegister, this, &MainWindow::SlotsSwitchReg);

    //创建RegisterDialog, 设置进MainWindow
    _register_dia = new RegisterDialog(this);

    //设置窗口样式
    _login_dia->setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
    _register_dia->setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
    //隐藏注册窗口，只显示登录窗口
    _register_dia->hide();
}

MainWindow::~MainWindow() {
    delete ui;
}

void MainWindow::SlotsSwitchReg() {
    setCentralWidget(_register_dia);
    _login_dia->hide();
    _register_dia->show();
}
